package com.elmcode.study.design.pro01_simplefactory;


import com.elmcode.study.design.pro01_simplefactory.constant.CarTypeConstant;
import com.elmcode.study.design.pro01_simplefactory.vo.Audi;
import com.elmcode.study.design.pro01_simplefactory.vo.Byd;
import com.elmcode.study.design.pro01_simplefactory.vo.Car;
import org.junit.jupiter.api.Test;

public class SimpleFactory {

    public static Car createCarFactory(String type){
        switch (type){
            case CarTypeConstant.AUDI:
                return new Audi();
            case CarTypeConstant.BYD:
                return new Byd();
            default:
                return null;
        }
    }


    @Test
    public void testSimpleFactory(){
        Car audi = SimpleFactory.createCarFactory(CarTypeConstant.AUDI);
        audi.run();

        Car byd = SimpleFactory.createCarFactory(CarTypeConstant.BYD);
        byd.run();
    }

}
